import qs from 'query-string'
import Axios from '../plugins/axios'
import { HTTPTypes } from './type'
import { baseURL, innerOrout } from './config'

export class ImageManage {
  /**
   * 上传图片url
   * @returns
   */
  static uploadImg(): string {
    return `${baseURL}/roms/operation/${innerOrout}/co/file/upload`
  }

  /**
   * 上传图片 没有用到
   * @param params
   * @returns
   */
  static async uploadImgReq(params: HTTPTypes['req']): Promise<HTTPTypes['res']> {
    return Axios.post(`${baseURL}/roms/operation/${innerOrout}/co/file/upload`, { ...params })
  }

  /**
   * 图片预览 获取临时访问key
   * @param params
   * @returns
   */
  static async getTemAccKey(params: HTTPTypes['req']): Promise<HTTPTypes['res']> {
    return Axios.post(`${baseURL}/roms/operation/${innerOrout}/co/file/getTemAccKey`, { ...params })
  }

  /**
   * 图片预览 获取当前可访问地址
   * @param params
   * @returns
   */
  static imageView(params: any): string {
    return `${baseURL}/roms/operation/${innerOrout}/co/file/view?${qs.stringify(params)}`
  }
}
